﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BLL.Interfaces;
using DAL.DBInteractions;
using POCOS;

namespace BLL
{
  public   class LogServices : ILogsServices
    {
         private readonly IUnitOfWork _unitofwork;

        public LogServices(IUnitOfWork unitofwork)
        {
            this._unitofwork = unitofwork;
        }

       




       
        public IEnumerable<ActionLogs> GetLogs()
        {
            return _unitofwork.LogsRepository.GetAll();
        }

        public ActionLogs GetLogsById(int id)
        {
            return _unitofwork.LogsRepository.GetById(id);
        }

        public void CreateLogs(ActionLogs Logs)
        {
            _unitofwork.LogsRepository.Add(Logs);
            _unitofwork.Commit();
        }

        public void UpdateLogs(ActionLogs Logs)
        {
            _unitofwork.LogsRepository.Update(Logs);
            _unitofwork.Commit();
        }

        public void DeleteLogs(int id)
        {

            _unitofwork.LogsRepository.Delete(GetLogsById(id));
            _unitofwork.Commit();

        }

        public ActionLogs Find(int id)
        {
          return _unitofwork.LogsRepository.Find(x => x.Id == id).FirstOrDefault();
        }

     

        public void SaveLogs()
        {
            _unitofwork.Commit();
        }
    }
}
